package com.example.occlusiondemo.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.eqgis.eqtool.tmp.BaseParameterManager;
import com.eqgis.eqtool.tmp.Utils;
import com.example.occlusiondemo.Log;
import com.example.occlusiondemo.PathConfig;
import com.example.occlusiondemo.R;
import com.supermap.ar.Point3D;
import com.supermap.ar.areffect.ConvertTool;
import com.supermap.ar.areffect.Location;
import com.supermap.hiar.AREngine;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

/**
 * 启动页
 */
public class StartActivity extends AppCompatActivity {
    public static boolean isDebug = true;
    public static boolean isOpenScan = true;
    private boolean loadCustomSetting = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Utils.hideBottomUIMenu(this);
        Utils.hideTopUI(this);
        //默认是请求AR应用所需的权限
        Utils.requestPermissions(this);
        //载入日志输出类
        Log.init(this, PathConfig.LOG_PATH);

        AREngine.enforceARCore();
//        AREngine.setUsingFixedCoordinate(false);

        setContentView(R.layout.activity_main_start);
        if (!isDebug){
            findViewById(R.id.mask_view).setVisibility(View.VISIBLE);
        }

        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                //添加自定义路径配置
                loadCustomSetting = PathConfig.useCustomSetting(StartActivity.this);
                if (loadCustomSetting){
                    timer.cancel();
                }
            }
        },500,1000);
        //墙面验证
//        startActivity(new Intent(this,PipeActivityVertical_lxk.class));
//        startActivity(new Intent(this,PipeActivityVertical.class));
//        startActivity(new Intent(this,MainActivity2.class));
//        this.finish();

//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//
//            }
//        }).start();
    }


    public void toDemo01(View view) {
        if (!loadCustomSetting) {
            Toast.makeText(this, "参数配置中，请稍后", Toast.LENGTH_SHORT).show();
            return;
        }
        startActivity(new Intent(this,PipeActivityVertical_lxk.class));
    }

    public void toDemo02(View view) {
        if (!loadCustomSetting) {
            Toast.makeText(this, "参数配置中，请稍后", Toast.LENGTH_SHORT).show();
            return;
        }
        startActivity(new Intent(this,PipeActivity.class));
        finish();
    }

    public void toTestActivity(View view) {
        if (!loadCustomSetting) {
            Toast.makeText(this, "参数配置中，请稍后", Toast.LENGTH_SHORT).show();
            return;
        }
        startActivity(new Intent(this,TestActivity.class));
    }
}